window.onload = function () {
    function deep(newObj, obj) {
        var o = newObj;
        for (var key in obj) {
            if (typeof obj[key] == 'object') {
                o[key] = obj[key].constructor === Array ? [] : {};
                deep(o[key], obj[key]);
            } else {
                o[key] = obj[key];
            }
        };
        return o;
    }
    var obj1 = {
        name: "DJ",
        age: 18,
        children: {
            name: "yh",
            age: 4
        }
    }
    var obj2 = deep({}, obj1);
    obj2.children.age = 5;
    console.log(obj1);
    console.log(obj2);
}